# Stage 1: Build the project using a verified Maven image
FROM maven:3.9-eclipse-temurin-17 AS build
WORKDIR /app
COPY pom.xml .
COPY .mvn/ .mvn/
RUN mvn dependency:go-offline
COPY src/ /app/src/
RUN mvn package -DskipTests


# Stage 2: Run using a standard, full JDK image (guaranteed to exist)
FROM openjdk:17-jdk AS final
WORKDIR /app
COPY --from=build /app/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]